<template>
    <div class="table_pane">
        <div class="table_body">
            <div class="icon_group">
                <div class="icon_item">
                     <el-icon><Plus /></el-icon>
                </div>
                <div class="icon_item">
                    <el-icon><RefreshRight @click="RefreshClick" /></el-icon>
                </div>
            </div>
            <el-table :data="tableData" style="width: 100%">
                <el-table-column fixed prop="title" label="收入" width="180" />
                <el-table-column prop="formUserName" label="转账用户" width="180" />
                <el-table-column prop="payMoney" label="转账金额" width="150" />
                <el-table-column prop="payNote" label="备注" width="150" />
                <el-table-column prop="payDate" label="转账时间" width="250" />
                <el-table-column fixed="right" label="Operations" min-width="120">
                <template #default>
                    <el-button link type="primary" size="small" @click="handleClick">
                    Detail
                    </el-button>
                    <el-button link type="primary" size="small">Edit</el-button>
                </template>
                </el-table-column>
            </el-table>
            <div class="page_pane">
                <el-pagination
                    :page-size="tableSize"
                    layout="total, prev, pager, next"
                    :total="tableTotal"
                    @prev-click="prevClick"
                    @next-click="nextClick"
                    @current-change="currentChange"
                />
            </div>
        </div>
    </div>
</template>
<script setup>
import { defineComponent,reactive, ref, unref, h, onMounted, nextTick, computed, getCurrentInstance} from 'vue'
import { useStore } from 'vuex';
import { accountPayApi } from '@/api/apis/pay'


//表数据
const pageNum=ref(0);
const tableData = ref([])
const tableTotal=ref(0);
const tableSize=ref(10);
const currentChange=(num)=>{
    pageNum.value=num;
    pageData(num);;
}
//上一页
const prevClick=(num)=>{
    pageNum.value=num;
    pageData(num);
}
//下一页
const nextClick=(num)=>{
    pageNum.value=num;
    pageData(num);
}
const RefreshClick=()=>{
    pageData(pageNum.value);
}
const pageData=(pageNum)=>{
        accountPayApi.payRecordIn({pageNum:pageNum,pageSize:tableSize.value}).then((res)=>{
        tableData.value=res.data;
        tableTotal.value=res.total;
    })
}
nextTick(()=>{
    //获取用户进账信息
    pageData(1);
})
//父组件刷新表格数据
const parentTableFlush=()=>{
    pageData(pageNum.value);
}
// 暴露方法给父组件
defineExpose({
    parentTableFlush
})
</script>
<style lang="css" scoped>
.table_pane{
    padding-right: 20px;
    box-sizing: border-box;
    .table_body{
        border: 1px solid #dcdfe6;
        padding: 10px 10px 40px 10px;
        box-sizing: border-box;
        .icon_group{
            box-sizing: border-box;
            padding-left: 5px;
            display: inline-flex;
            .icon_item{
                margin-right: 5px;
            }
        }
        .page_pane{
            padding-left: 20px;
            margin-top: 10px;
            box-sizing: border-box;
        }
    }
}
</style>